package org.zoomdev.zoom.dao;

/**
 * 与SQL语句相关的方法
 *
 * @param <T>
 */
public interface Sql<T extends Sql> extends Select<T>, Insert<T>, Update<T>, Delete<T> {


    static Select newSelect() {
        return new SelectImpl("*");
    }


    enum Statistics {
        MAX("MAX(%s)"),
        MIN("MIN(%s)"),
        SUM("SUM(%s)"),
        AVG("AVG(%s)"),
        COUNT("COUNT(%s)");


        private final String select;

        Statistics(String select) {
            this.select = select;
        }


        public String toSelect(String key) {
            return String.format(select, key);
        }
    }

    class PlaceHolder {
        final String value;
        final Object[] args;

        public PlaceHolder(String value, Object[] args) {
            this.value = value;
            this.args = args;
        }

        static PlaceHolder of(String value, Object... args) {
            return new PlaceHolder(value, args);
        }
    }


}
